<!--  -->
<template>
  <div>
  {{ treeData }}

  <el-tree
    style="max-width: 600px"
    :data="treeData"
    :props="defaultProps"

  />
  </div>
</template>

<script lang='ts' setup>
import { reactive,toRefs,ref,onMounted} from 'vue'
import { buildTree } from '../../utils/treeUtil';

const defaultProps = {
  children: 'children',
  label: 'name',
}
const treeData=ref<any>();

const getData=()=>{

    var list1= [
            {
                "id": 2260,
                "companyId": 1307,
                "name": "3单元",
                "addTime": "2025-07-04 10:33:44",
                "addAccountId": 100247,
                "pid": 2255
            },
            {
                "id": 2259,
                "companyId": 1307,
                "name": "2单元",
                "addTime": "2025-07-04 10:33:38",
                "addAccountId": 100247,
                "pid": 2255
            },
            {
                "id": 2258,
                "companyId": 1307,
                "name": "1单元",
                "addTime": "2025-07-04 10:33:32",
                "addAccountId": 100247,
                "pid": 2255
            },
            {
                "id": 2257,
                "companyId": 1307,
                "name": "2单元",
                "addTime": "2025-07-04 10:33:25",
                "addAccountId": 100247,
                "pid": 2254
            },
            {
                "id": 2256,
                "companyId": 1307,
                "name": "1单元元",
                "addTime": "2025-07-04 10:33:14",
                "addAccountId": 100247,
                "pid": 2254
            },
            {
                "id": 2255,
                "companyId": 1307,
                "name": "2号楼",
                "addTime": "2025-07-04 10:33:07",
                "addAccountId": 100247,
                "pid": 0
            },
            {
                "id": 2254,
                "companyId": 1307,
                "name": "1号楼",
                "addTime": "2025-07-04 10:33:03",
                "addAccountId": 100247,
                "pid": 0
            }
        ];

 var list2=[
            {
                "id": 1147,
                "companyId": 1307,
                "buildingId": 2256,
                "buildingName": "1号楼1单元元",
                "type": 683,
                "typeName": "豪华间",
                "name": "1010",
                "beds": 11,
                "picture": "upload/2025/7/4/20250704103539724.jpg",
                "addTime": "2025-07-04 10:35:40",
                "addAccountId": 100247,
                "addAccountName": "贾政12"
            },
            {
                "id": 1146,
                "companyId": 1307,
                "buildingId": 2260,
                "buildingName": "2号楼3单元",
                "type": 683,
                "typeName": "豪华间",
                "name": "102房",
                "beds": 11,
                "picture": "upload/2025/7/4/20250704103512317.jpg",
                "addTime": "2025-07-04 10:35:21",
                "addAccountId": 100247,
                "addAccountName": "贾政12"
            },
            {
                "id": 1145,
                "companyId": 1307,
                "buildingId": 2260,
                "buildingName": "2号楼3单元",
                "type": 683,
                "typeName": "豪华间",
                "name": "101房",
                "beds": 100,
                "picture": "upload/2025/7/4/20250704103448060.jpg",
                "addTime": "2025-07-04 10:34:48",
                "addAccountId": 100247,
                "addAccountName": "贾政12"
            }
        ]


        treeData.value=   buildTree(list1,list2);
 

}
getData();
</script>
<style scoped>
</style>